package com.apes.framework.jpa.spec.specification;

import javax.persistence.criteria.*;

public class IsNotNullSpecification extends AbstractSpecification{
    private final String property;

    public IsNotNullSpecification(String property) {
        this.property = property;
    }


    @Override
    public Predicate toPredicate(Root root, CriteriaQuery query, CriteriaBuilder cb) {
        From from = getRoot(property, root);
        String field = getProperty(property);
        return cb.isNotNull(from.get(field));
    }
}
